package gui5e;

import java.util.*;

import processing.core.PApplet;
import controlP5.*;

public class RightPanel extends Panel{

	//fields
		
		//constructors
		public RightPanel(int s_, int pr_, PApplet pa_, ControlP5 c_){
			super(s_, pr_, pa_);
			  ctrl = c_;
			  accordion =  ctrl.addAccordion("acc_r");
			  x=pa_.getWidth();
		}
		
		//methods
		
		/// the update method for the panel
		public void draw(PApplet p_){
			if(!isExisting){
				 for (Map.Entry<String, Group> entry : ctrlGroups.entrySet()) {
					    Group group_ = entry.getValue();
					    accordion.addItem(group_)
					    	.setPosition(p_.getWidth()-GUI.panelRightWidth+(x-10), GUI.innerTop +20)
					    	.setWidth(GUI.panelRightWidth - 20)
					    	;
					}
				  {{accordion.open(1);}};
				isExisting=true;
			}
				if(!isWaiting){
				//size&position  
				switch(mode_){
						case 's': if(x> p_.getWidth() - GUI.panelRightWidth) x = x - GUI.PanelSpeed; else mode_ = 'v';break;  
						case 'h': if(x< p_.getWidth()) x = x + GUI.PanelSpeed; else mode_ = 'm';break;
						case 'v': x=p_.getWidth()-GUI.panelRightWidth; break;
						case 'm': x=p_.getWidth(); break;
				 } 
				//background
				p_.fill(GUI.backgroundPanel[0],GUI.backgroundPanel[1],GUI.backgroundPanel[2], GUI.backgroundPanel[3]);
				if(GUI.borderPanel.length < 2) p_.noStroke(); else p_.stroke(GUI.borderPanel[0],GUI.borderPanel[1],GUI.borderPanel[2], GUI.borderPanel[3]);
				GUI.innerWidth= p_.getWidth()-x;
				p_.rect(x, GUI.innerTop, GUI.panelRightWidth, GUI.innerHeight);	  
				//toolboxes
				ctrl.draw();
				accordion.setPosition((x+10), GUI.innerTop +20);
				}	    
			}
	
}
